package main.com.sun.jeecgexam.struts.listener;

import main.com.sun.jeecgexam.struts.config.ConfigParseUtil;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * Created by sun on 2017/3/29.
 */
public class StrutsListener implements ServletContextListener {
    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        // 获从context-param节点中获得struts-config文件路径
//        servletContextEvent.getServletContext().getc
        // 读取strutsconfig 配置文件

//        // 初始化该servlet的时候 读取init-param
//        String xmlPath = ("struts-config");
//        xmlPath = this.getServletContext().getRealPath("") + xmlPath;
//        log("xmlPath: " + xmlPath);
//
//        Map<String, ActionMapping> actionMappingMap = ConfigParseUtil.ParseStrutsConfig(xmlPath);
//
//        this.getServletContext().setAttribute("StrutsConfigLoaded","1");
//        this.getServletContext().setAttribute("StrutsConfigContent",actionMappingMap);
//        ConfigParseUtil.ParseStrutsConfig()
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {

    }
}
